const {
  gethomedata,
  getgoodscount
} = require("../../api/api.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodscount: 0, //商品总数
    swiperdata: [], //轮播图数据
    couponList: [], //优惠券数据
    griddata: [], //宫格数据
    grouponList: [], //团购数据
    brandList: [], //品牌制造商
    newGoodsList: [], //新品首发
    hotGoodsList: [], //人气推荐
    topicList:[],//专题精选
    floorGoodsList:[]//居家等
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    gethomedata().then(res => {
      console.log(res);
      let {
        banner,
        couponList,
        channel,
        grouponList,
        brandList,
        newGoodsList,
        hotGoodsList,
        topicList,
        floorGoodsList
      } = res.data
      this.setData({
        swiperdata: banner,
        couponList: couponList,
        griddata: channel,
        grouponList: grouponList,
        brandList: brandList,
        newGoodsList: newGoodsList,
        hotGoodsList:hotGoodsList,
        topicList:topicList,
        floorGoodsList:floorGoodsList
      })
    })
    getgoodscount().then(res => {
      console.log(res);
      this.setData({
        goodscount: res.data.goodsCount
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})